<template>
    <div>
        <Table border :columns="columns" :data="tableData"></Table>
    </div>
</template>

<script>
import ajax from '../../../../libs/axios.js'
export default {
    props: {
        tableData: Array,
        access: Object
    },
    data () {
        return {
            itemTotal: 0,      // 条数
            data: [],
            columns: [
                {
                    title: '序号',
                    type: 'index',
                    width: 80,
                    align: 'center'
                },
                {
                    title: '订单编号',
                    align: 'center',
                    key: 'orderNo',
                    width:200
                },
                {
                    title: '购车订单',
                    align: 'center',
                    key: 'tradeOrderId',
                    width:120
                },
                {
                    title: '车辆信息',
                    align: 'center',
                    key: 'carSeries',
                    width:180
                },
                {
                    title: '始发城市',
                    align: 'center',
                    key: 'beginCity',
                    width:180
                },
                {
                    title: '目的地',
                    align: 'center',
                    key: 'endCity',
                    width:180,
        },
                {
                    title: '状态',
                    align: 'center',
                    key: 'orderStatus',
                    width:80,
                    render: (h, params) => {
                        if (params.row.orderStatus === 1) {
                            return h('span', '待处理')
                        }  else if(params.row.orderStatus === 2) {
                            return h('span', '待确认')
                        } else if(params.row.orderStatus === 3) {
                            return h('span', '待安排')
                        } else if(params.row.orderStatus === 4) {
                            return h('span', '待发运')
                        } else if(params.row.orderStatus === 5) {
                            return h('span', '运输中')
                        } else if(params.row.orderStatus === 6) {
                            return h('span', '待收车')
                        } else if(params.row.orderStatus === 7) {
                            return h('span', '已完成')
                        } else if(params.row.orderStatus === -1) {
                            return h('span', '已取消')
                        }else {
                            return h('span', '其他')
                        }
                    }
                },
                {
                    title: '车商名称',
                    align: 'center',
                    key: 'partyName',
                    width:140
                },
                {
                    title: '创建时间',
                    align: 'center',
                    key: 'createTime',
                    width:180
                },
                {
                    title: '操作',
                    key: 'action',
                    width: 120,
                    fixed:'right',
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h(
                                'Button',
                                {
                                    props: {
                                        type: 'primary',
                                        size: 'small'

                                    },
                                    style: {
                                        marginRight: '5px',
                                        display: this.access.edit === true ? 'inline-block' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.infoData(params.row.id)
                                        }
                                    }
                                },
                                '查看详情'
                            )
                        ])
                    }
                }
            ],

        }
    },
    created () {
        this.init()
    },
    activated () {
        this.init()
    },
    methods: {
        // 数据初始化
        init () {},
        // 查看详情
        infoData (id) {
            let argu = {
                id: id
            }
            this.$router.push({
                name: 'ordercancel_detail',
                params: argu
            })
        },
    },
}
</script>
